package com.love.rongapi.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.love.rongapi.mapper.LogMapper;
import com.love.rongapi.model.Log;
import com.love.rongapi.service.LogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Slf4j
@Service
public class LogServiceImpl extends ServiceImpl<LogMapper, Log> implements LogService {

    @Override
    public void saveLog(Log log) {
        this.save(log);
    }

    @Override
    public List<Log> findLog(LocalDateTime beginTime, LocalDateTime endTime) {
        LambdaQueryWrapper<Log> wrapper = Wrappers.<Log>lambdaQuery()
//                .between(Log::getCreateTime, beginTime, endTime)
                .gt(Log::getCreateTime, beginTime)
                .lt(Log::getCreateTime, endTime);
        return this.list(wrapper);
    }
}
